package com.itxiao.controller;
import com.itxiao.entity.SysRole;
import com.itxiao.pojo.bo.Page;
import com.itxiao.pojo.vo.R;
import com.itxiao.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * (SysRole)表控制层
 *
 * @author makejava
 * @since 2025-09-17 17:14:43
 */
@RestController
@RequestMapping("admin/api/v1/sys-role")
@Api(tags = "系统角色模块")
@CrossOrigin
public class SysRoleController  {
    /**
     * 服务对象
     */
    @Resource
    private SysRoleService sysRoleService;

    @ApiOperation("分页查询")
    @PostMapping("/query")
    public R queryList(@RequestBody Page page) {
        return sysRoleService.queryList(page);
    }

    @ApiOperation("添")
    @PostMapping("/add")
    public R add(@RequestBody SysRole sysRole) {
        return sysRoleService.add(sysRole);
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public R update(@RequestBody SysRole sysRole) {
        return sysRoleService.updateInfo(sysRole);
    }

    @ApiOperation("删除")
    @DeleteMapping("/delete")
    public R deleteBatch(@RequestBody List<Integer> ids) {
        return sysRoleService.del(ids);
    }

    @ApiOperation("单个删除")
    @DeleteMapping("/delete/{id}")
    public R deleteById(@PathVariable Integer id) {
        return sysRoleService.del(Collections.singletonList(id));
    }

}

